<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/common.js"></script>
</head>
<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "travelCommend" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>游记推荐管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/travelCommend/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                        <label>关键字</label>
                        <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!}">
                    </div>
                    <div class="form-group">
                        <select  class="form-control"  id="typeBtn" name="type" value="${(qo.type)!}">
                            <option value="-1">全部</option>
                            <option value="1">每周推荐</option>
                            <option value="2">每月推荐</option>
                            <option value="3">攻略推荐</option>
                        </select>
                        <script>
                            $("#typeBtn").val(${(qo.type)!});
                        </script>
                    </div>
                    <button id="btn_query" class="btn btn-success">
                        <span class="glyphicon glyphicon-search"></span> 查询
                    </button>
<#--
                    <a  id="inputBtn" class="btn btn-success" >添加推荐游记</a>
-->
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>封面</th>
                        <th>标题</th>
                        <th>副标题</th>
                        <th>推荐时间安排</th>
                        <th>推荐类型</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
					<#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index+1}</td>
                        <td><img src='${entity.coverUrl}' width="30px"/></td>
                        <td>${entity.title}</td>
                        <td>${entity.subTitle}</td>
                        <td>${entity.schedule?string("yyyy-MM-dd")}</td>
                        <td>${entity.typeName}</td>
                        <td>
                            <a href="javascript:void(0);" class="changeBtn"  data-json='${entity.json}'>修改</a>
                        </td>
                    </tr>
					</#list>
                    </tbody>
                </table>

              <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>

<div id="travelCommendModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="commendForm" class="form-horizontal" method="post" action="/travelCommend/saveOrUpdate.do" enctype="multipart/form-data" style="margin: -3px 118px">
                <#--游记推荐表的id-->
                    <input id="travelCommendId" type="hidden" name="id" value="" />
                <#--游记的id-->
                    <input id="travelId" type="hidden" name="travelId" value="" />
                    <div class="form-group">
                        <label class="col-sm-4 control-label">标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title" placeholder="标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">副标题</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="subTitle" name="subTitle" placeholder="副标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">封面</label>
                        <div class="col-sm-6">
                            <img id="coverUrl" width="200px"/><#--用来显示的封面图片-->
                            <input type="hidden" name="coverUrl" /><#--用来提交表单的-->
                            <input type="file" class="form-control"  name="file" ><#--用来上传文件的控件-->
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">推荐时间</label>
                        <div class="col-sm-6">
                            <input type="text" id="schedule" name="schedule" class="form-control" onclick="WdatePicker()">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">推荐类型</label>
                        <div class="col-sm-6">
                            <select id="type" class="form-control" autocomplete="off" name="type" >
                                <option value="1">每周推荐</option>
                                <option value="2">每月推荐</option>
                                <option value="3">攻略推荐</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" style="text-align: center">
                        <a href="javascript:void(0)" target="_blank" id="skip">点击查看游记文章明细</a>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        //修改按钮
        $(".changeBtn").click(function () {
            //获取自定义的json属性
            var json=$(this).data("json");
            console.log(json);
            //回显隐藏域的id
            $("#travelCommendId").val(json.id);
            $("#travelId").val(json.travelId);

            $("#title").val(json.title);
            $("#subTitle").val(json.subTitle);
            $("#schedule").val(json.schedule);
            $("#type").val(json.type);
            $("#coverUrl").attr("src",json.coverUrl);//回显封面
            //图片隐藏域
            $("#commendForm input[name='coverUrl']").val(json.coverUrl);
            //处理a连接的标签
            $("#skip").attr("href","/travel/releaseList.do?travelId="+json.travelId);
            $("#travelCommendModal").modal("show");
        });
        //推荐按钮提交
        $("#saveBtn").click(function () {
            $("#commendForm").ajaxSubmit(function (data) {
                doSuccess();
            });
        });
    });
</script>

</body>
</html>